<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <link rel="icon" href="*{/images/favicon.ico}" type="image/x-icon" />
  <meta http-equiv="P3P" content="CP='NOI NID'">
  <meta http-equiv="_broadcast_from_" Content="1" />
  <script type="text/javascript" src="*{/js/jquery.js}"></script>
  <script type="text/javascript" src="*{/js/func.js}"></script>
  <script type="text/javascript" src="*{/js/base64.js}"></script>
  <script type="text/javascript" src="*{/js/md5.js}"></script>
<style>
html,body{
  margin:0;
  padding:0;
}
</style>
	<title>臣信软件内部调试工具</title>
<style type="text/css">
html, body { padding:0px; margin:0px; }
.row {
    margin-left:30px;
    margin-top:20px;
    font-size:13px;
}
a {color:bule;font-weight:bold;font-size:14px;text-decoration:none}
a:hover{color:red;}
a:active{color:yellow;}

#sql_history #sql_time {
  text-align:center;
	width:140px;
	margin:0px;
	padding:0px;
}
#sql_history #sql_source {
  text-align:center;
	padding-left:3px;
	padding-right:3px;
}
#sql_history #sql_content {
	padding:3px;
}
#sql_history #sql_deal{
	width:40px;
	text-align:center;
	padding:3px;
}
.sys_info_th {
  background-color:#EEEEEE;
  font-weight:bold;
  padding:5px;
  text-align:right;
}
.sys_info_td {
  padding:5px;
  text-align:left;
}
</style>
</head>
<body>
<div class="main_div">
    <div class="row">
         <a href="*{/sm/log.html}" target="_blank" >日志监控</a>&nbsp;&nbsp;------------------------> <a href="*{/N100082.ha}" target="_blank" style="color:#ffcc00;font-weight:normal;">【备份当前日志】</a>
    </div>
    <div class="row">
        <a href="*{/editor/index.htm}" target="_blank">进入代码管理</a>
    </div>
    <div class="row">
        <a href="*{/file/index.htm}" target="_blank">进入文件管理</a>
    </div>
    <div class="row">
        <a href="*{/N100040.ha}&execute=1" onclick="javascript:if(!confirm('确认重启？')){return false;}" target="_blank">重启应用</a>
    </div>
    <div class="row" block_type="db"  style="display:none;">
        查询数据：<br />
        <form method="POST" id="exesql" action="*{/N100038.ha}" target="_blank">
           <table border="1">
            <tr>
                <td>数据源主键：<select id="source" name="source" tabIndex="1"></select><span title="当前查询记录数上限">记录数</span>：
                  <input type="text" id="pagesize" name="pagesize" value="50" style="width:40px;text-align:center;"/>
                  <span title="用来跳过开头多少条记录">页数</span>： <input type="text" id="pageno" name="pageno" value="1" style="width:40px;text-align:center;"/>
                <span title="勾选后才能执行更新语句，否则只能执行查询语句">更新语句</span>：<input type="checkbox" name="doexecute" id="doexecute" value="1" onclick="javascript:if(this.checked){alert('注意：一旦语句写错，会导致整个表数据丢失!!!');}" />
                <span title="文件保存到WEB-INF/upload文件夹中">保存到文件</span>：<input type="checkbox" name="savefile"  value="1" />
                </td>
            </tr>
            <tr>
                <td>
					语句：<textarea style="width:600px;height:100px;"  id="exesql_sql_show" tabIndex="2"  onkeydown="javascript:checkKeyDo(event);"></textarea>
					<input type="hidden" id="exesql_sql" name="sql" />
				</td>
            </tr>
            <tr>
                <td align="center">
                  <span title="特殊查询语句">特殊语句</span>：<input type="checkbox" name="spquery" id="spquery" value="1" onclick="javascript:if(this.checked){alert('注意：仅用于获取少量记录的特殊查询语句，比如获取所有表名，否则会导致内存溢出!!!');}" />
                  &nbsp;&nbsp;&nbsp;&nbsp;
                  <input type="button" value="执行"  onclick="javascript:doExeSql();"/>
                </td>
            </tr>
           </table>
        </form>
    </div>
    <div class="row" block_type="db" style="display:none;height:300px;width:670px;overflow:scroll;">
      <table border="1" cellpadding="0" cellspacing="0"  bordercolor="black" width="100%">
        <tbody id="sql_history"></tbody>
      </table>
    </div>
    <div class="row" style="border:solid 1px blue;width:500px;padding-left:10px;margin-top:30px;margin-bottom:30px;padding: 3px 5px;">
        新的主键：
        <input type="text" id="newid"/>
        <input type="button" value="生成" style="margin-left:10px;" onclick="javascript:$('#newid').val(getUrlValue('*{/N100142.ha}'));"/>
    </div>
    <div class="row" style="border:solid 1px blue;width:500px;padding-left:10px;margin-top:30px;margin-bottom:30px;">
        <p>补丁维护：</p>
        <p style="line-height:20px;"><a href="*{/N100029.ha}" target="_blank" style="border:solid 1px #AAAAAA;color:black;background: linear-gradient(#FFFFFF,#DDDDDD);padding:5px;font-weight:normal;font-size:12px;text-decoration:none;">备份及当前全部脚本</a></p>
        <div style="margin-bottom:20px;">
          <form action="*{/sync/local_sync.htm}" method="POST" enctype="multipart/form-data" target="_blank">
            <span>上传及比对补丁：</span>
            <input type="file" name="ufile" style="border:solid 1px #CCCCCC;"/>
            <input type="submit" value="提交" />
          </form>
        </div>
    </div>
    <div class="row" style="width:500px;padding-left:10px;margin-top:30px;margin-bottom:30px;">
        <input type="button" value="重置字段缓存" onclick="javascript:resetFieldBuffer();"/>
    </div>   
    <div class="row" block_type="db"  style="display:none;">
        生成Insert语句：<br />
        <form method="POST" id="outsql" action="*{/N100039.ha}" target="_blank">
           <table border="1">
            <tr>
                <td>数据源主键：<select id="source" name="source" tabIndex="1"></select>&nbsp;&nbsp;对应表名：<input type="text" id="table_name" name="table_name" onkeydown="javascript:checkKeyDo2(event);"/>&nbsp;&nbsp;
				生成文件：<input type="checkbox" name="out_file" value="1"/>
                   &nbsp;&nbsp;
                   <input type="button" value="重置表状态" onclick="javascript:resetTableState();"/>
                </td>
            </tr>
            <tr>
                <td>
					语句：<textarea style="width:500px;height:100px;" id="outsql_show_countsql"></textarea>
					<input type="hidden" id="outsql_countsql" name="count_sql" />
				</td>
            </tr>
            <tr>
                <td>
					语句：<textarea style="width:500px;height:100px;" id="outsql_show_sql"></textarea>
					<input type="hidden" id="outsql_sql" name="sql" />
				</td>
            </tr>
            <tr>
                <td align="center"><input type="button" value="执行" onclick="javascript:
                		$('#outsql_countsql').val(Base64.e64($('#outsql_show_countsql').val()));
						        $('#outsql_sql').val(Base64.e64($('#outsql_show_sql').val()));
                    submit();
				"/></td>
            </tr>
           </table>
        </form>
    </div>
    <div class="row" block_type="db"  style="display:none;">
        导出数据到CSV：<br />
        <form method="POST" id="outcsv" action="*{/N100097.ha}" target="_blank">
           <table border="1">
            <tr>
                <td>数据源主键：<select id="source" name="source" tabIndex="1"></select>&nbsp;&nbsp;单引号：<input type="checkbox" name="dyh" value="1"/>
                </td>
            </tr>
            <tr>
                <td>
					语句：<textarea style="width:500px;height:100px;" id="outcsv_show_countsql"></textarea>
					<input type="hidden" id="outcsv_countsql" name="count_sql" />
				</td>
            </tr>
            <tr>
                <td>
					语句：<textarea style="width:500px;height:100px;" id="outcsv_show_sql"></textarea>
					<input type="hidden" id="outcsv_sql" name="sql" />
				</td>
            </tr>
            <tr>
                <td align="center"><input type="button" value="执行" onclick="javascript:
                		$('#outcsv_countsql').val(Base64.e64($('#outcsv_show_countsql').val()));
						        $('#outcsv_sql').val(Base64.e64($('#outcsv_show_sql').val()));
                    submit();
				"/></td>
            </tr>
           </table>
        </form>
    </div>
    <div class="row" block_type="db"  style="display:none;">
        生成数据字典：<br />
        <form method="POST" id="builddbdict" action="*{/dbdict/tlist.html}" target="_blank">
           <table border="1">
            <tr>
                <td>数据源主键：<select id="source" name="source" tabIndex="1"></select></td>
            </tr>
            <tr>
                <td align="center"><input type="submit" value="显示所有表"/></td>
            </tr>
           </table>
        </form>
    </div>
    <div class="row" block_type="db"  style="display:none;">
        批量执行脚本：<a href="*{/N100087.ha}&view=true" target="_blank">查看执行状态</a><br />
        <form method="POST" id="batchexescript" enctype="multipart/form-data"  action="*{/N100087.ha}" target="_blank">
           <table border="1">
            <tr>
                <td>数据<span ondblclick="javascript:$('#proxy_area').show();">源</span>主键：<select id="source" name="source" tabIndex="1"></select>
                </td>
            </tr>
            <tr>
                <td>脚本文件：<input type="file" name="upload" /></td>
            </tr>
            <tr>
                <td align="center"><input type="submit" value="执行"/></td>
            </tr>
           </table>
        </form>
    </div>
    <div _action="N100115">
      <input type="hidden" id="proxy_enabled"/>
      <div class="row" id="cluster_enabled">
         集群模式中，当前服务器名：<span id="cluster_local_name"></span>&nbsp;（主服务器：<span id="cluster_master"></span>）&nbsp;&nbsp;<input type="button" value="取消代理" onclick="javascript:cancelProxy();"/>
      </div>
      <div class="row">
        集群状态信息：<input type="button" value="刷新" onclick="javascript:showClusterList();"/>
        &nbsp;&nbsp;&nbsp;&nbsp;<a href="*{/sm/rsl.html}" target="_blank"><input type="button" value="查看集群中支持的脚本代码信息"/></a>
        <br /><br />
        <div id="cluster_list"></div>
      </div>
    </div>
    <div style="margin-top:30px;"></div>
    <div>
      <div class="row">
         文件保护：<span id="file_guard_status"></span>&nbsp;&nbsp;<input type="button" value="刷新" onclick="javascript:showFileGuard();"/>
      </div>
      <div class="row" id="file_guard_area" style="display:none;">
        <table border="1">
          <tr>
            <th class="sys_info_th">是否禁用：</th>
            <td id="fg_disabled" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">是否准备重启中：</th>
            <td id="fg_ready_reboot" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">是否初始化：</th>
            <td id="fg_inited" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">是否共享模式：</th>
            <td id="fg_share_mode" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">累计检查本地文件次数：</th>
            <td id="fg_check_count" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">检查本地文件数量：</th>
            <td id="fg_file_count" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">本地文件减少数量：</th>
            <td id="fg_reduce_file_count" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">上次检查本地文件时间：</th>
            <td id="fg_last_check_time" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">是否正在检查本地文件：</th>
            <td id="fg_has_checking" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">累计被同步次数：</th>
            <td id="fg_sync_count" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">上次被同步文件时间：</th>
            <td id="fg_sync_time" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">是否正在被同步文件：</th>
            <td id="fg_has_sync" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">累计发送文件数量：</th>
            <td id="fg_send_file_count" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">累计接收文件数量：</th>
            <td id="fg_res_file_count" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">累计删除文件数量：</th>
            <td id="fg_del_file_count" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">当前群组（文件组）：</th>
            <td id="fg_group" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">监控本地文件路径：</th>
            <td id="fg_paths" class="sys_info_td"></td>
          </tr>
        </table>
      </div>
    </div>
    <div style="margin-top:30px;"></div>
    <div>
      <div class="row">
         故障<span id="clear_log_alert" title="双击消除全部故障码">码</span>监控：<span id="log_alert_status"></span>&nbsp;&nbsp;<input type="button" value="刷新" onclick="javascript:showLogAlert();"/>
      </div>
      <div class="row" id="log_alert_area"></div>
    </div>
    <div style="margin-top:30px;"></div>
    <div>
      <div class="row">
         系统信息：<input type="button" value="刷新" onclick="javascript:showSysInfo();"/>
      </div>
      <div class="row">
        <table border="1" id="sys_info_area">
          <tr>
            <th class="sys_info_th">开发模式：</th>
            <td id="devMode" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">内核版本：</th>
            <td id="kernelVer" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">服务器时间：</th>
            <td id="serverTime" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">启动时间：</th>
            <td id="showStartTime" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">运行时间：</th>
            <td id="startUsedTime" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">程序根目录：</th>
            <td id="serverBasePath" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">操作系统：</th>
            <td id="osName" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">操作系统版本号：</th>
            <td id="osVersion" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">处理器数量：</th>
            <td id="processorsCount" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">本机IP地址：</th>
            <td id="ips" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">系统临时目录：</th>
            <td id="sysTempPath" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">服务器信息（综合信息）：</th>
            <td id="serverInfo" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">服务器用户信息（综合信息）：</th>
            <td id="serverUserInfo" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">JAVA版本号：</th>
            <td id="javaVer" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">编译类型：</th>
            <td id="osArch" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">JAVA安装目录：</th>
            <td id="javaBasePath" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">Servlet容器信息：</th>
            <td id="servletInfo" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">最大内存：</th>
            <td id="maxMemory" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">当前总内存：</th>
            <td id="totalMemory" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">使用内存：</th>
            <td id="usedMemory" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">当前剩余内存：</th>
            <td id="freeMemory" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th">剩余内存占比：</th>
            <td class="sys_info_td" style="position:relative;padding:0;border:solid 1px #CCCCCC;">
              <div id="mem_percent" style="position:absolute;left:0px;top:0px;text-align:center;overflow:hidden;color:#888888;height:25px;line-height:25px;"></div>
            </td>
          </tr>
          <tr>
            <th class="sys_info_th" onclick="javascript:refreshCpuInfo();">CPU占用率：</th>
            <td id="cpuTotal" class="sys_info_td"></td>
          </tr>
          <tr>
            <th class="sys_info_th" onclick="javascript:refreshCpuInfo();">当前进程CPU占用率：</th>
            <td class="sys_info_td"><span id="cpuCurrent"></span><span id="cpuPid"></span></td>
          </tr> 
         <tr id="no_cache_area">
            <th class="sys_info_th" title="不包含图片缓存控制">HTTP缓存状态：</th>
            <td class="sys_info_td" style="position:relative;padding:0;border:solid 1px #CCCCCC;">
              &nbsp;&nbsp;<span id="no_cache_status"></span>&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" id="no_cache_bt" value="禁用" status="" onclick="javascript:doChangeNoCache(1);"/>
            </td>
          </tr>
         <tr id="no_cache_img_area">
            <th class="sys_info_th">图片缓存状态：</th>
            <td class="sys_info_td" style="position:relative;padding:0;border:solid 1px #CCCCCC;">
              &nbsp;&nbsp;<span id="no_cache_img_status"></span>&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" id="no_cache_img_bt" value="禁用" status="" onclick="javascript:doChangeNoCache(2);"/>
            </td>
          </tr>
        </table>
      </div>
    </div>
    <div>
      <div class="row">
         脚本编码信息：<input type="button" value="刷新" onclick="javascript:refreshScriptCode();"/>
      </div>
      <div class="row" id="script_code_area"></div>
    </div>
    <div style="margin-top:30px;"></div>
    <div style="margin-left:30px;">
      <div class="row" style="display:table-cell;">
         <span style="vertical-align:top;">待处理内容：</span><textarea id="fix_code_area" style="width:500px;height:80px;font-size:12px;"></textarea>
         <br /><input type="button" title="标准的Base64编码" value="Base64.toBase64 标准编码" onclick="javascript:doBase64(true,false,true);"/>
         <br /><input type="button" title="用于框架内部的Base64编码" value="Base64.e64 内部编码" onclick="javascript:doBase64(true);"/>
         <br /><input type="button" title="用于框架内部的，并且准备提交到后台的数据做编码" value="Base64.pe64 内部编码（用于POST提交数据）" onclick="javascript:doBase64(true);"/>
         <br /><input type="button" title="用于框架内部编码的值做解码" value="Base64.d64 内部解码" onclick="javascript:doBase64(false);"/>
          <br /><input type="button" title="用于标准Base64解码" value="Base64.d64 标准解码" onclick="javascript:doBase64(false,false,true);"/>
          <br /><input type="button" value="MD5处理（小写）" onclick="javascript:doMd5();"/>
          <br /><input type="button" value="MD5处理（大写）" onclick="javascript:doMd5(true);"/>
          <br /><input type="button" value="URL编码" onclick="javascript:doUrlEnc(true);"/>
          <br /><input type="button" value="URL解码" onclick="javascript:doUrlEnc();"/>
          <br /><input type="button" value="内部路径解码" title="解密当前内部加密url，问号后面，&符号前面的加密路径字符串）" onclick="javascript:doNativeDec();"/>
      </div>
    </div>
    <div style="margin-top:150px;"></div>
</div>
<script type="text/javascript">
//设置数据源下拉框
var sourceData = getJson("*{/N100116.ha}");
if(sourceData){
  sourceData = sourceData["rs"];
}
setArraySelectNode($("#exesql").find("#source"),sourceData); 
setArraySelectNode($("#outsql").find("#source"),sourceData); 
setArraySelectNode($("#outcsv").find("#source"),sourceData); 
setArraySelectNode($("#builddbdict").find("#source"),sourceData); 
setArraySelectNode($("#batchexescript").find("#source"),sourceData); 
if(sourceData.length>0){
  $("div").find("[block_type='db']").show();
}


function showSysInfo(){
  var res = getJson("*{/N100120.ha}");
  var area = $("#sys_info_area");
  
  if(res.devMode=="1"){
    area.find("#devMode").css("background-color","red").html("<span style=\"color:white;font-weight:bold;\">是</span>");
  }else{
    area.find("#devMode").css("background-color","white").text("否");
  }
  area.find("#kernelVer").text(res.kernelVer);
  area.find("#serverTime").text(res.serverTime);
  area.find("#showStartTime").text(res.showStartTime);
  area.find("#startUsedTime").text(res.startUsedTime);
  area.find("#serverBasePath").text(res.serverBasePath);
  area.find("#osName").text(res.osName);
  area.find("#osVersion").text(res.osVersion);
  area.find("#processorsCount").text(res.processorsCount);
  area.find("#sysTempPath").text(res.sysTempPath);
  area.find("#serverInfo").text(res.serverInfo);
  area.find("#serverUserInfo").text(res.serverUserInfo);
  area.find("#javaVer").text(res.javaVer);
  area.find("#osArch").text(res.osArch);
  area.find("#javaBasePath").text(res.javaBasePath);
  area.find("#servletInfo").text(res.servletInfo);
  area.find("#maxMemory").text(res.maxMemory);
  area.find("#totalMemory").text(res.totalMemory);
  area.find("#usedMemory").text(res.usedMemory);
  area.find("#freeMemory").text(res.freeMemory);
  area.find("#mem_percent").attr("value",res.usedMemoryPercent);
  area.find("#ips").html(res.ips.replace(",","<br />"));
}
showSysInfo();


function resetTableState(){
 var form = $("#outsql");
 var source = form.find("#source").val();
 var tableName = form.find("#table_name").val();
 if(source=="" || tableName==""){
  alert("需要输入数据源主键和表名");
  return;
 }
 var res = getJson("*{/N100131.ha}","source="+source+"&tableName="+tableName);
 if(!res){
   return;
 }
 alert(res.msg);
}

function resetFieldBuffer(){
 var res = getJson("*{/N100131.ha}");
 if(!res){
   return;
 }
 alert(res.msg);
}

function doChangeNoCache(changeType){
  var area    = $("#no_cache_area");
  var imgArea = $("#no_cache_img_area");
  var res = getJson("*{/N100129.ha}","change_type="+changeType);
  if(!res || res.status!="1"){
    area.hide();
    imgArea.hide();
    return;
  }
  area.show();
  if(res.no_cache=="1"){
    area.find("#no_cache_status").text("禁用");
    area.find("#no_cache_bt").val("点击启用").attr("status","1");
  }else{
    area.find("#no_cache_status").text("启用");
    area.find("#no_cache_bt").val("点击禁用").attr("status","0");
  }
  imgArea.show();
  if(res.no_cache_img=="1"){
    imgArea.find("#no_cache_img_status").text("禁用");
    imgArea.find("#no_cache_img_bt").val("点击启用").attr("status","1");
  }else{
    imgArea.find("#no_cache_img_status").text("启用");
    imgArea.find("#no_cache_img_bt").val("点击禁用").attr("status","0");
  }
}
doChangeNoCache();

function showClusterList(){
  if($("#cluster_enabled").lenght<1){
    return; 
  }
  var tbArea = $("#cluster_list");
  tbArea.empty();
  var res = getJson("*{/N100117.ha}");
  if(res==null || res.status!=1){
    return; 
  }
  var proxyDisabled = $("#proxy_enabled").val()=="1"?false:true;
  res = res.list.rs;
  showSysInfo();
  var tb = [
     '<table border="1">'
    ,'<tr style="background-color:#EEEEEE;">'
    ,'  <th style="padding-left:3px;padding-right:3px;">Index</th>'
    ,'  <th style="padding-left:3px;padding-right:3px;">Group</th>'
    ,'  <th style="padding-left:3px;padding-right:3px;">ServerName</th>'
    ,'  <th style="padding-left:3px;padding-right:3px;">Master</th>'
    ,'  <th style="padding-left:3px;padding-right:3px;">StartTime</th>'
    ,'  <th style="padding-left:3px;padding-right:3px;">RunTime</th>'
    ,'  <th style="padding-left:3px;padding-right:3px;">IP</th>'
    ,'  <th style="padding-left:3px;padding-right:3px;">URL</th>'
    ,'  <th style="padding-left:3px;padding-right:3px;">Context</th>'
    ,'  <th style="padding-left:3px;padding-right:3px;">Local</th>'
    ,'  <th style="padding-left:3px;padding-right:3px;">Disabled</th>'
    ,'  <th style="padding-left:3px;padding-right:3px;">ValidSend</th>'
    ,'  <th style="padding-left:3px;padding-right:3px;">SendTime</th>'
    ,'  <th style="padding-left:3px;padding-right:3px;">ValidReceive</th>'
    ,'  <th style="padding-left:3px;padding-right:3px;">ReceiveTime</th>'
    ,'  <th style="padding-left:3px;padding-right:3px;">Deal</th>'
    ,'</tr>'
  ];
  for(var i=0;i<res.length;i++){
    tb.push(
       '<tr>'
      ,'  <td style="padding-left:3px;padding-right:3px;text-align:center;">',res[i]._no,'</td>'
      ,'  <td style="padding-left:3px;padding-right:3px;text-align:center;">',res[i].group,'</td>'
      ,'  <td style="padding-left:3px;padding-right:3px;text-align:center;">',res[i].name,'</td>'
      ,'  <td style="padding-left:3px;padding-right:3px;text-align:center;',(res[i].master=='1'?'background-color:#ffcc66;':''),';">',res[i].master,'</td>'
      ,'  <td style="padding-left:3px;padding-right:3px;text-align:center;">',(res[i].local=="1"?$("#showStartTime").text():res[i].startTime),'</td>'
      ,'  <td style="padding-left:3px;padding-right:3px;text-align:center;">',(res[i].local=="1"?$("#startUsedTime").text():res[i].runTime),'</td>'
      ,'  <td style="padding-left:3px;padding-right:3px;">',res[i].ip,'</td>'
     ,'  <td style="padding-left:3px;padding-right:3px;">',res[i].url,'</td>'
     ,'  <td style="padding-left:3px;padding-right:3px;text-align:center;">',res[i].context,'</td>'
     ,'  <td style="padding-left:3px;padding-right:3px;text-align:center;',(res[i].local=='1'?'background-color:#EEEEEE;':''),';">',res[i].local,'</td>'
     ,'  <td style="padding-left:3px;padding-right:3px;text-align:center;',(res[i].disabled=='1'?'background-color:#EEEEEE;':''),'">',res[i].disabled,'</td>'
   );
   if(res[i].local=="1"){
     tb.push(
        '  <td style="padding-left:3px;padding-right:3px;text-align:center;background-color:#66ff33;">',res[i].validSend,'</td>'
       ,'  <td style="padding-left:3px;padding-right:3px;text-align:center;background-color:#66ff33;">',res[i].sendTime,'</td>'
       ,'  <td style="padding-left:3px;padding-right:3px;text-align:center;background-color:#66ff33;">',res[i].validReceive,'</td>'
       ,'  <td style="padding-left:3px;padding-right:3px;text-align:center;background-color:#66ff33;">',res[i].receiveTime,'</td>'
       ,'  <td style="padding-left:3px;padding-right:3px;text-align:center;background-color:#EEEEEE;">-</td>'
     );
   }else{
     tb.push(
        '  <td style="padding-left:3px;padding-right:3px;text-align:center;background-color:',(res[i].validSend=='0'?'#F5DEB3':'#66ff33'),';">',res[i].validSend,'</td>'
       ,'  <td style="padding-left:3px;padding-right:3px;text-align:center;background-color:',(res[i].validSend=='0'?'#F5DEB3':'#66ff33'),';">',res[i].sendTime,'</td>'
       ,'  <td style="padding-left:3px;padding-right:3px;text-align:center;background-color:',(res[i].validReceive=='0'?'#F5DEB3':'#66ff33'),';">',res[i].validReceive,'</td>'
       ,'  <td style="padding-left:3px;padding-right:3px;text-align:center;background-color:',(res[i].validReceive=='0'?'#F5DEB3':'#66ff33'),';">',res[i].receiveTime,'</td>'
     );
     if(res[i].validSend=="0" || proxyDisabled){
       tb.push('  <td style="padding-left:3px;padding-right:3px;text-align:center;background-color:#F5DEB3;">-</td>');
     }else{
       tb.push('  <td style="padding-left:3px;padding-right:3px;text-align:center;"><a href="*{/proxy/index.htm}&key=',res[i].name,'" title="GoGoGo A Lei A Lei A Lei" target="_blank">Go</a></td>');
     }
   }
   tb.push('</tr>');
  }
  tb.push('</table>');
  tbArea.append(tb.join(''));
}
showClusterList();


function showLogAlert(){
  var res  = getJson("*{/N100128.ha}");
  var area = $("#log_alert_area").empty();
  var msg  = $("#log_alert_status").text("");
  if(res==null){
    return;
  }
  msg.text(res.msg);
  
  res = res.list;
  if(res==null){
    return;
  }
  var tb = [
     '<table border="1">'
    ,'<tr style="background-color:#EEEEEE;">'
    ,'  <th style="padding-left:3px;padding-right:3px;">故障代码</th>'
    ,'  <th style="padding-left:3px;padding-right:3px;">故障名称</th>'
    ,'  <th style="padding-left:3px;padding-right:3px;">首次发生时间</th>'
    ,'  <th style="padding-left:3px;padding-right:3px;">最后发生时间</th>'
    ,'  <th style="padding-left:3px;padding-right:3px;" nowrap>发生次数</th>'
    ,'</tr>'
  ];
  for(var i=0;i<res.length;i++){
    tb.push(
       '<tr style="height:30px;">'
      ,'  <td style="padding-left:3px;padding-right:3px;text-align:center;" nowrap>',res[i].code,'</td>'
      ,'  <td style="padding-left:3px;padding-right:3px;text-align:center;" nowrap title="',Base64.d64(res[i].explain),'">',res[i].title,'</td>'
      ,'  <td style="padding-left:3px;padding-right:3px;text-align:center;" nowrap>',res[i].stime,'</td>'
      ,'  <td style="padding-left:3px;padding-right:3px;text-align:center;" nowrap>',res[i].etime,'</td>'
      ,'  <td style="padding-left:3px;padding-right:3px;text-align:center;" nowrap>',res[i].count,'</td>'
      ,'</tr>'
    );
  }
  tb.push('</table>');
  area.append(tb.join(''));
}
showLogAlert();
$("#clear_log_alert").on("dblclick",function(){
  var res  = getJson("*{/N100128.ha}&do_clear=1");
  var msg  = $("#log_alert_status").text("");
  if(res==null){
    return;
  }
  if(res.status=="1"){
    $("#log_alert_area").empty()
  }
  msg.text(res.msg);
});


function showFileGuard(){
  var res = getJson("*{/N100127.ha}");
  var area = $("#file_guard_area");
  if(!res){
    return;
  }
  if(res.loaded=="1"){
    area.show();
    $("#file_guard_status").text("启用");
  }else{
    area.hide();
    $("#file_guard_status").text("禁用");
    return;
  }
  
  var paths = "";
  if(res.path_list.rs){
    for(var i=0;i<res.path_list.rs.length;i++){
      if(paths.length>0){
        paths += "<br />";
      }
      paths += res.path_list.rs[i];
    }
  }
  
  area.find("#fg_disabled").text(res.disabled=="0"?"否":"是").css("color",res.disabled=="0"?"green":"red");
  area.find("#fg_inited").text(res.inited=="0"?"否":"是").css("color",res.inited=="1"?"green":"red");
  area.find("#fg_share_mode").text(res.share_mode=="0"?"否":"是");
  area.find("#fg_check_count").text(res.check_count);
  area.find("#fg_reduce_file_count").text(res.reduce_file_count);
  area.find("#fg_file_count").text(res.file_count);
  area.find("#fg_last_check_time").text(res.last_check_time);
  area.find("#fg_has_checking").text(res.has_checking=="0"?"否":"是");
  area.find("#fg_sync_count").text(res.sync_count);
  area.find("#fg_sync_time").text(res.last_sync_time);
  area.find("#fg_has_sync").text(res.has_sync=="0"?"否":"是");
  area.find("#fg_send_file_count").text(res.send_file_count);
  area.find("#fg_res_file_count").text(res.res_file_count);
  area.find("#fg_del_file_count").text(res.del_file_count);
  area.find("#fg_ready_reboot").text(res.ready_reboot=="1"?"是":"否").css("color",res.ready_reboot=="1"?"red":"green");
  area.find("#fg_group").text(res.group);
  area.find("#fg_paths").text(paths);
}
showFileGuard();



function doExeSql(){

  	$("#sql_history").prepend("<tr><td id=\"sql_time\">"+now()+"</td><td id=\"sql_source\">"
    	+$("#exesql").find("#source").val()+"</td><td id=\"sql_content\">"
        +$("#exesql").find("#exesql_sql_show").val()
        +"</td><td id=\"sql_deal\"><input type=\"hidden\" id=\"sql_pageno\" value=\""
        +$("#exesql").find("#pageno").val()+"\" /><input type=\"hidden\" id=\"sql_pagesize\" value=\""
        +$("#exesql").find("#pagesize").val()+"\" /><input type=\"button\" value=\"使用\" onclick=\"javascript:showSqlHistory(this);\"/></td></tr>");
  
                
	$('#exesql_sql').val(Base64.e64($('#exesql_sql_show').val()));
	$("#exesql")[0].submit();
	document.getElementById('doexecute').checked=false;
    document.getElementById('spquery').checked=false;
}
function showSqlHistory(node){
  var trNode = $(node.parentNode.parentNode);
  $("#exesql").find("#source").val(trNode.find("#sql_source").text());
  $("#exesql").find("#exesql_sql_show").val(trNode.find("#sql_content").text());
  $("#exesql").find("#pagesize").val(trNode.find("#sql_pagesize").val());
  $("#exesql").find("#pageno").val(trNode.find("#sql_pageno").val());
}
function checkKeyDo(evt){
	if(!evt.ctrlKey ){
		return;
	}
	if(evt.keyCode==13){
		doExeSql();
	}
}


function doOpenLog(node){
	var action = document.getElementById("log_action").value;
	var sessionKey = document.getElementById("log_session_key").value;
	var serverName = document.getElementById("server_name").value;
	var param = "";
	if(action){
		param = "action="+action;
	}
	if(sessionKey){
		if(param){
			param += "&";
		}
		param += "session_key="+sessionKey;
	}
	if(serverName){
		if(param){
			param += "&";
		}
		param += "server_name="+serverName;
	}
	var url = node.getAttribute("a_href");
	if(param){
		url += "?"+param;
	}
	node.href = url;
}
function now(){
  var date = new Date();
  var res = date.getFullYear()+"-";
  var val = date.getMonth()+1;
  if(val<10){
   res += "0"+val; 
  }else{
    res += val;
  }
  res += "-";
  val = date.getDate();
  if(val<10){
    res += "0"+val;
  }else{
    res += val;
  }
  res += " ";
  val = date.getHours();
  if(val<10){
    res += "0"+val;
  }else{
    res += val;
  }
  res += ":";
  val = date.getMinutes();
  if(val<10){
    res += "0"+val;
  }else{
    res += val;
  }
  res += ":";
  val = date.getSeconds();
  if(val<10){
    res += "0"+val;
  }else{
    res += val;
  }
  return res;
}

//通过百分比值返回不同的css颜色描述 由绿到红
//background-color
function hslColPerc(percent,startCol,endCol) {
  if(!startCol){
    startCol = 0;
  }
  if(!endCol){
    endCol = 120;
  }
  var color = percent/100,
	 color = endCol*color+startCol;
	//Return a CSS HSL string
	return 'hsl('+color+',100%,50%)';
}

//处理剩余内存占比
var memPercent = $("#mem_percent");
function setMemPercent(){
  var memPercentParent = memPercent.parent();
  var percentValue     = ""+(100-memPercent.attr("value"));
  var point = percentValue.indexOf(".");
  if(point>0 && percentValue.length>point+3){
    percentValue = percentValue.substr(0,point+3);
  }
  memPercent
    .width(memPercentParent.width()/100*percentValue)
    .css("background-color",hslColPerc(percentValue))
    .text(percentValue+"%")
    .attr("title",percentValue+"%");
}
setMemPercent();


memPercent
  .on("dblclick",function(){
    getJson("*{/N100123.ha}");
    memPercent
      .fadeOut(200,null,function(){
        window.setTimeout(function(){
          var res = getJson("*{/N100120.ha}");
          if(res && res.status=="1"){
            var area = $("#sys_info_area");
            memPercent.attr("value",res.usedMemoryPercent);
            area.find("#usedMemory").html(res.usedMemory);
            area.find("t#freeMemory").html(res.freeMemory);
            setMemPercent();
          }
          memPercent.fadeIn(1500);
        },3000)
      });
  });

function cancelProxy(){
  getJson("*{}/__stop_proxy.ha");
  alert("解除执行完毕，请重新刷新页面")
}

//刷新CPU占用率
function refreshCpuInfo(){
  $("#cpuTotal").text("--");
  $("#cpuCurrent").text("--");
  $("#cpuPid").text("");
  //获取CPU占用率
  getUrlValue("*{/N100132.ha}",null,null,function(res){
    $("#cpuTotal").text(res.total);
    $("#cpuCurrent").text(res.current);
    $("#cpuPid").text("  PID:("+res.pid+")");
  });
};
refreshCpuInfo();

//刷新脚本编码信息
function refreshScriptCode(){
  $("#script_code_area").text(getUrlValue("*{/N100133.ha}"));
}
refreshScriptCode();


//base64转码
function doBase64(isEnc,usePost,noNative){
  var cnt = $("#fix_code_area").val();
  if(cnt==""){
    return;
  }
  if(isEnc){
    if(noNative){
      $("#fix_code_area").val(Base64.toBase64(cnt));
    } else if(usePost){
      $("#fix_code_area").val(Base64.pe64(cnt));
    }else{
      $("#fix_code_area").val(Base64.e64(cnt));
    }
  }else{
    if(noNative){
      $("#fix_code_area").val(Base64.fromBase64(cnt));
    }else{
      $("#fix_code_area").val(Base64.d64(cnt));
    }
  }
}

function doMd5(upper){
  var cnt = $("#fix_code_area").val();
  if(cnt==""){
    return;
  }
  cnt = md5(cnt);
  if(upper){
    cnt = cnt.toUpperCase();
  }
  $("#fix_code_area").val(cnt);
}

function doUrlEnc(isEnc){
  var cnt = $("#fix_code_area").val();
  if(cnt==""){
    return;
  }
  if(isEnc){
    cnt = encodeURIComponent(cnt);
  }else{
    cnt = decodeURIComponent(cnt);
  }
  $("#fix_code_area").val(cnt);
}

function doNativeDec(){
  var cnt = $("#fix_code_area").val();
  if(cnt==""){
    return;
  }
  cnt = getUrlValue("*{/N100147.ha}","p="+cnt);
  console.log(cnt);
  $("#fix_code_area").val(cnt);
}
</script>
</body>
</html>